package org.flyweight;

import java.util.HashMap;

public class PeopleFactory {
	private static HashMap<String,People> pool = new HashMap<String, People>();
	
	public static People getPeople(String key){
		People people = null;
		
		if (!pool.containsKey(key)) {
			System.out.println(key+"----------创建对象，并放置池中");
			people = new PeoplePool(key);
			pool.put(key, people);
		} else {
			people = pool.get(key);
			System.out.println(key+"----------直接从池中取得对象");
		}
		
		return people;
	}
}
